﻿<%@ Control Language="C#" Inherits="System.Web.Mvc.ViewUserControl<SDT.Site.ViewModels.ProductListModels>" %>
<%@ Import Namespace="SDT.Lib.Helpers" %>
<div class="tit_bgoff mar_t"><div class="tit_off"><%=ViewData["Title"] %></div></div>
<div class="bg-div">
	<%foreach (var item in Model.Products)
   {
       var path = "/deal/details/" + item.ID + "/" + Html.ToUrlFriendly(item.Name);
   %>
	<div class="div1">
   	  <div class="tit_div1">
   	    <a href="<%=path %>"  class="link_gr"><%=Html.Encode(item.Name) %></a>
   	  </div>
   	  <%var total_order=item.OrderDetails.Where(e=>e.Order.TypeID==SDT.Lib.Common.OrderType.Deal).ToList().Sum(e=>e.Quantity);
        var reorder = item.MaxVoucher.HasValue && item.MaxVoucher.Value - total_order>0 ? item.MaxVoucher.Value - total_order : 0;
        var strreorder = reorder > 0 ? string.Format("Còn {0} phiếu",reorder) : "Đã hết hàng";%>
      <div class="note">Đã mua: <%=total_order%> | Còn: <%=item.MaxVoucher - total_order%> phiếu</div>
      <div class="pad_l5">Giá: <span class="t_red"><strong><%=string.Format("{0:0,0}",item.UnitPrice) %> ₫</strong></span></div>
    </div>
    <div class="div2" align="center">
        <div class="tit_div2">
            <span>Giảm</span>
            <div class="font_4"><%=string.Format("{0:0,0}", item.DiscountPercent) %>%</div>
        </div>
    </div>
    <div class="clear"></div>
    <div class="div2-sfam">
    	<% string imgPath = (item.ImagePath != null && item.ImagePath != string.Empty) ? SDT.Lib.Common.Utils.GenThumbnail(item.ID, 90, 90, item.ImagePath, Model.ImagePath, Model.ImageUrl) : SDT.Lib.Common.Globals.DefaultLogo; %>
    	<a href="<%=path %>">
    	    <img src="<%=imgPath %>" title="<%=item.Name %>" alt="<%=item.Name %>" width="90px" height="90px" class="bor-img" />
    	</a>
    </div>
    <div class="div2-cnt">
	    <div><%=Html.Encode(item.Summary) %></div>
        <div class="f_r"><a href="<%=path %>" class="link_dt"> >>Chi tiết</a></div>
        <div class="clear"></div>
    </div>
    <div class="clear"></div>
    <%} %>
</div>

